import Vue from 'vue'
import VueRouter from 'vue-router'
import api from "./api"

Vue.use(VueRouter)
var paths = [];
for (let string of api) {
    if(string.indexOf("$") === 0){
        var str = string.substring(1);
        var i = str.indexOf(":");
        str = str.substring(0, i);
        paths.push({
            path: str,
            name: str,
            component: () => import(`../components/${str}.vue`)
        })
    } else {
        paths.push({
            path: string,
            name: string,
            component: () => import("../components/Doc.vue")
        })
    }
}

const routes = [
    {
        path: '/',
        name: 'main',
        component: () => import("../views/Doc.vue"),
        children: [
            {
                path: '/',
                redirect: paths[1].name,
            },
            ...paths
            // {
            //   path: 'userTable',
            //   name:"userTable",
            //   component: () => import("../views/userTable.vue"),
            // },
            // {
            //   path: 'edit',
            //   name:'userEdit',
            //   component: () => import("../views/userEdit.vue"),
            // },
            // {
            //   path: 'import',
            //   component: () => import("../views/userImport.vue"),
            // }
        ]
    },

];

const router = new VueRouter({
    routes
})

export default router
